﻿var ToolBarConfig = {
    Menu: {
        File: {
            description: '任务调整 ',
            Items: {
                SetPath: { id: 'SetPath', tag: '设置路径' },
                EditPath: { id: 'EditPath', tag: '编辑路径' },
                AdjustParticipant: { id: 'AdjustParticipant', tag: '更改人员' },
                Adjust: { id: 'Adjust', tag: '更改人员' }
            }
        },
        
        History: {
            description: '查看历史',
            Items: {
                AllHistory: { id: 'AllHistory', tag: '全部历史' },
                ActivityHistory: { id: 'ActivityHistory', tag: '步骤历史' }

            }
        }
    },
    InitialToolBar: function () {
        var me = this;
        $.each(ToolBarConfig.Menu, function (j, menu) {
            var toolBar = $("<div>").css({ "height": "auto" });
            var tilte = $("<div>").attr("class", "divTitle");
            var titleImag = $("<img>").css({ "width": "6", "margin-left": "10px" }).attr("src", "/assets/js/workflow/images/toolbar/expand.png");
            tilte.append(titleImag);
            var tilteDescription = $("<span style='margin-left:5px;font-size:11px;font-family:SimSun;'>" + menu.description + "</span>");
            tilte.append(tilteDescription);
            toolBar.append(tilte);
            var itemContainer = $("<div>");
            tilte.click(function () {
                var display = itemContainer.css("display");
                if (display == "none") {
                    itemContainer.slideDown();
                    titleImag.attr("src", "/assets/js/workflow/images/toolbar/expand.png");
                }
                else {
                    itemContainer.slideUp();
                    titleImag.attr("src", "/assets/js/workflow/images/toolbar/shrink.png");
                }
            });

            var j = 0;
            $.each(menu.Items, function (i, val) {
                var toolBarItem = $("<div>").attr("class", "divItem").mouseover(function () {
                    toolBarItem.css({ "background-color": "#ffefbb", "border": "1px solid #e5c365" });
                }).mouseout(function () {
                    toolBarItem.css({ "background-color": "transparent", "border": "0px solid transparent" });
                }).mousedown(function () {
                    toolBarItem.css({ "background-color": "#fdf6de", "border": "1px solid #e5c365" });
                    isDoubleClickCommand = false;
                    me.mousedownCallBack(i);
                }).dblclick(function () {
                    isDoubleClickCommand = true;
                    me.mousedownCallBack(i);
                })

                var jss = val.js;
                var toolBarDescription = $("<div>").attr("class", "divToolBarDescription");
                toolBarDescription.html(val.tag);
                var divToolBarImage = $("<div>").attr("class", "divToolBarImage");
                var image = $("<img>").css({ "height": "13", "width": "auto" }).attr("src", "/assets/js/workflow/images/toolbar/" + i + ".png");
                divToolBarImage.append(image);
                toolBarItem.append(divToolBarImage);
                toolBarItem.append(toolBarDescription);
                itemContainer.append(toolBarItem)
                ++j;
            });
            toolBar.append(itemContainer);
            itemContainer.css({ "height": j * 21 + 5 });

            $("#toolBar").append(toolBar)
        });
    },
    mousedownCallBack: function (command) {
        switch (command) {
            case 'SetPath':
                Command = command;
                break;
            case 'EditPath':
                Command = command;
                break;
            case 'AdjustParticipant':
                Command = command;
                break;
            case 'ActivityHistory':
                Command = command;
                break;
            case 'AllHistory':

                break;

        }

    }

}
